import { Component, OnInit, Output, EventEmitter } from '@angular/core';

import { RemoveTableService } from 'app/public/serve/remove-table/remove-table.service';
import { HintsService } from 'app/public/serve/hints/hints.service';
import { Service } from 'app/server/server';

import { scopeUrl } from '../scope.url';

@Component({
  selector: 'scopes-delete',
  templateUrl: './scopes-delete.component.html',
  styleUrls: ['./scopes-delete.component.css']
})

export class ScopesDeleteComponent implements OnInit {

  @Output() delete = new EventEmitter<void>();

  constructor(
    private removeTableService: RemoveTableService, 
    private hintsService: HintsService,
    private server: Service,
  ) {}

  ngOnInit() {
  }

  /**
   * 删除
   */
  _delete() {  

    this.removeTableService
        .confirmRemove('scopesId', this.server.baseUrl + scopeUrl.delete)
        .then(res=>{
          if(res.result_code == '0000') {
            this.delete.emit();
          }
          this.hintsService._operationHints(res.message, res.result_code);
          return
        })
        .catch(err=> {
          this.hintsService._operationHints('error', 'error');
          return
        })
  }

}
